
#include "stdafx.h"
#include "CommandDef.h"
#include "Util/UtilInclude.h"
#include "IResCfg.h"
#include "CSubConPainter.h"
#include "CSubClubSetCon.h"
#include "CZoomTimeCtrl.h"
#include "cmyreg.h"
CSubClubSetCon::CSubClubSetCon(HWND hWnd):CSubCon(hWnd)
{
	m_Rect.SetRect(0,0,355,454);
	m_iPage=0;
	m_iStep=58;
	m_CSAFEIndex=0;
	m_UnitIndex=0;
	m_CKAYAKIndex=0;


}

CSubClubSetCon:: ~CSubClubSetCon(void)
{

}
BOOL CSubClubSetCon::ChangeLangaue()
{

	 LANGUAGE_DECLARE;
	wstring strLang=CConfig::GetInstance()->GetLanguage();

     pLang->SetLanguageFile(strLang.c_str());
	CUtil::TrimFileExtension(strLang);
	m_pLanText->SetCaption(LAN_GETTEXT(strLang));
	wstring langbmp=strLang;

	CPicture *pic=(CPicture *)ControlFromID(CMD_MSG_SUBSET_LANGPIC);
	langbmp=langbmp+L".bmp";

	wstring strLangPic=L"Lang\\"+langbmp;

	pic->SetPic(CUtil::LoadBitmapEx(strLangPic,0));
	return true;

}

BOOL CSubClubSetCon::InitControls(DWORD dwData)
{

	//message box
	LANGUAGE_DECLARE;
	FONT_DECLARE;

	HBITMAP hBitmap = NULL;

	CIResCfg ResCon;
	if(!ResCon.Init(L"SubMSGClubSet.xml"))
	{
		//g_App.ShowMsgBox(CMD_MSGBOX_OK,L"",LAN_GETTEXT(Msg_ResError));
		return FALSE;
	}

	m_nAniType  = ResCon.GetAniType();
	m_nExitAniType=ResCon.GetExitAniType();
	m_nAniSpeed = ResCon.GetAniSpeed();
	SetRect(ResCon.GetRect());
	BOOL bFromDll = ResCon.IsResFromDll();
	BtnParam btnInfo;

	hBitmap = CUtil::LoadBitmapEx(ResCon.GetImage(),bFromDll);


	BatTimePicParam picInfo;
	CBmpBtn* pBtn = NULL;
	TextParam txtInfo;
	CText* pText=NULL; 

	ResCon.GetBatTimePicParam(picInfo,L"Pic_Bkgnd");
	CPicture *pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC, L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	ResCon.SetPicParam(pPic,picInfo);




	/*ResCon.GetBatTimePicParam(picInfo,L"ClubSet_LanBK");
	pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	ResCon.SetPicParam(pPic,picInfo);*/

	ResCon.GetBatTimePicParam(picInfo,L"ClubSet_Unit");
	pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	ResCon.SetPicParam(pPic,picInfo);

	ResCon.GetBatTimePicParam(picInfo,L"ClubSet_NumberBK1");
	m_pPicMaxTime = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSG_SUBSET_PICNUM1));
	ResCon.SetPicParam(m_pPicMaxTime,picInfo);

	ResCon.GetBatTimePicParam(picInfo,L"ClubSet_NumberBK2");
	m_pPicPauseTime = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSG_SUBSET_PICNUM2));
	ResCon.SetPicParam(m_pPicPauseTime,picInfo);


	ResCon.GetBatTimePicParam(picInfo,L"ClubSet_KAYAK");
	pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	ResCon.SetPicParam(pPic,picInfo);

	ResCon.GetBatTimePicParam(picInfo,L"ClubSet_CSAFE");
	pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSGBOX_PIC));
	ResCon.SetPicParam(pPic,picInfo);



	ResCon.GetBatTimePicParam(picInfo,L"LangIcon");
	pPic = (CPicture*)AddControl(new CPicture(SWS_STATIC,L"",picInfo.m_rc, CMD_MSG_SUBSET_LANGPIC));
	ResCon.SetPicParam(pPic,picInfo);





	

	//ResCon.GetTextParam(txtInfo,L"CText_LAN");
	//pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_DEFAULTLAN),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	//ResCon.SetTextParam(pText,txtInfo);

	ResCon.GetTextParam(txtInfo,L"CText_UNIT");
	pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_DEFAULTUNIT),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	ResCon.SetTextParam(pText,txtInfo);



	ResCon.GetTextParam(txtInfo,L"CText_MAXWORKOUTTIME");
	pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_WORKOUTTIME_MAX),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	ResCon.SetTextParam(pText,txtInfo);

	ResCon.GetTextParam(txtInfo,L"CText_MAXPAUSETIME");
	pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_PAUSETIME_MAX),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	ResCon.SetTextParam(pText,txtInfo);

	ResCon.GetTextParam(txtInfo,L"CText_CABLEKAYAK");
	pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_CABLEKATAK),txtInfo.m_rc, CMD_MSG_SUBSET_CSAFETEXT_TITLE));
	ResCon.SetTextParam(pText,txtInfo);

	ResCon.GetTextParam(txtInfo,L"CText_CSAFE");
	pText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(MSG_HS_CLUBSETTING_CSAFE),txtInfo.m_rc, CMD_MSGBOX_TEXT));
	ResCon.SetTextParam(pText,txtInfo);



	/*ResCon.GetBtnParam(btnInfo,L"ClubSet_LAN_BTN");
	pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_CLUBSET_LAN));
	ResCon.SetBtnParam(pBtn,btnInfo);*/

	ResCon.GetBtnParam(btnInfo,L"ClubSet_CHOOSE_BTN");
	pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_UNIT));
	ResCon.SetBtnParam(pBtn,btnInfo);


	ResCon.GetBtnParam(btnInfo,L"ClubSet_NUM1_BTN_LEFT");
	pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_MAXTIME_LEFT));
	ResCon.SetBtnParam(pBtn,btnInfo);



	ResCon.GetBtnParam(btnInfo,L"ClubSet_NUM1_BTN_RIGHT");
	pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_MAXTIME_RIGHT));
	ResCon.SetBtnParam(pBtn,btnInfo);

	ResCon.GetBtnParam(btnInfo,L"ClubSet_NUM2_BTN_LEFT");
	pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_PAUSETIME_LEFT));
	ResCon.SetBtnParam(pBtn,btnInfo);


	ResCon.GetBtnParam(btnInfo,L"ClubSet_NUM2_BTN_RIGHT");
	pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_SUBSET_BTN_PAUSETIME_RIGHT));
	ResCon.SetBtnParam(pBtn,btnInfo);


	ResCon.GetBtnParam(btnInfo,L"ClubSet_CHOOSE_KAYA_BTN");
	pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_CLUBSET_BTN_KAYA));
	ResCon.SetBtnParam(pBtn,btnInfo);

	ResCon.GetBtnParam(btnInfo,L"ClubSet_CHOOSE_CSAFE_BTN");
	pBtn = (CBmpBtn*)AddControl(new CBmpBtn(SBS_RECT,L"",btnInfo.m_rc, CMD_MSG_CLUBSET_BTN_CSAFE));
	ResCon.SetBtnParam(pBtn,btnInfo);


	ITimeNumInfo btpInfo;
	ResCon.GetTimeNumParam(btpInfo,L"TimeNum_Workout");
	m_pMaxTimeCtrl = (CZoomTimeCtrl*)AddControl(new CZoomTimeCtrl(SBS_RECT, L"", btpInfo.m_rc, CMD_MSG_SUBSET_MAXTIME));
	ResCon.SetTimeNumParam(m_pMaxTimeCtrl,btpInfo);
	m_pMaxTimeCtrl->SetDecimalDigit(2);
    DWORD dwWorkTimer= CConfig::GetInstance()->GetMaxWorkoutTimes();//CConfig::GetInstance()->GetRegDWORD(L"MAXWorkTime");

	m_pMaxTimeCtrl->Set_INT_Value(dwWorkTimer/60);
	m_pMaxTimeCtrl->SetDecimalValue(dwWorkTimer%60);
	if (m_pMaxTimeCtrl->Get_INT_Value()<=5)
	{
		m_pMaxTimeCtrl->Set_INT_Value(5);
		m_pMaxTimeCtrl->SetDecimalValue(0);
	}

	if (m_pMaxTimeCtrl->Get_INT_Value()>=60)
	{
		m_pMaxTimeCtrl->Set_INT_Value(60);
		m_pMaxTimeCtrl->SetDecimalValue(0);
	}



	ResCon.GetTimeNumParam(btpInfo,L"TimeNum_Pause");
	 DWORD dwPauseTimer=CConfig::GetInstance()->GetMaxPauseTimes();//CConfig::GetInstance()->GetRegDWORD(L"MAXPauseTime");
	m_pPAUSETimeCtrl = (CZoomTimeCtrl*)AddControl(new CZoomTimeCtrl(SBS_RECT, L"", btpInfo.m_rc, CMD_MSG_SUBSET_PASUETIME));
	ResCon.SetTimeNumParam(m_pPAUSETimeCtrl,btpInfo);
    m_pPAUSETimeCtrl->SetDecimalDigit(2);
     m_pPAUSETimeCtrl->Set_INT_Value(dwPauseTimer/60);
	 m_pPAUSETimeCtrl->SetDecimalValue(dwPauseTimer%60);
	 if (m_pPAUSETimeCtrl->Get_INT_Value()==0&&m_pPAUSETimeCtrl->GetDecimalValue()<=10)
	 {
		 m_pPAUSETimeCtrl->Set_INT_Value(0);
		 m_pPAUSETimeCtrl->SetDecimalValue(10);
	 }

	 if (m_pPAUSETimeCtrl->Get_INT_Value()>=2)
	 {
		 m_pPAUSETimeCtrl->Set_INT_Value(2);
		 m_pPAUSETimeCtrl->SetDecimalValue(0);
	 }

	
	 wstring strLang=CConfig::GetInstance()->GetLanguage();

	 CUtil::TrimFileExtension(strLang);

	 ResCon.GetTextParam(txtInfo,L"LangText");
	 m_pLanText = (CText*)AddControl(new CText(SWS_STATICTEXT,LAN_GETTEXT(strLang),txtInfo.m_rc, CMD_MSG_SUBSET_LANGTEXT));
	 ResCon.SetTextParam(m_pLanText,txtInfo);

	 m_UnitText.push_back(LAN_GETTEXT(MSG_HS_CLUBSETTING_UNIT_US));
	 m_UnitText.push_back(LAN_GETTEXT(MSG_HS_CLUBSETTING_UNIT_METRIC));

	 m_CSAFEText.push_back(LAN_GETTEXT(MSG_HS_CLUBSETTING_UNIT_CSAFEOFF));
	 m_CSAFEText.push_back(LAN_GETTEXT(MSG_HS_CLUBSETTING_UNIT_CSAFEON));
	 m_CKAYAKText.push_back(LAN_GETTEXT(MSG_HS_CLUBSETTING_UNIT_DISABLE));
     m_CKAYAKText.push_back(LAN_GETTEXT(MSG_HS_CLUBSETTING_UNIT_ENABLE));



	 m_UnitIndex=CConfig::GetInstance()->GetRegDWORD(TEXT("Unit_Weight_KG"));
  

   


	 ResCon.GetTextParam(txtInfo,L"UnitText");
	 m_pUnitText = (CText*)AddControl(new CText(SWS_STATICTEXT, m_UnitText[m_UnitIndex],txtInfo.m_rc, CMD_MSG_SUBSET_UNITTEXT));
	 ResCon.SetTextParam(m_pUnitText,txtInfo);



	ResCon.GetTextParam(txtInfo,L"CABLEKAYAK_TEXT");

	m_CKAYAKIndex=CConfig::GetInstance()->GetRegDWORD(L"CABLEKAYAK");
	m_pCKAYAKText = (CText*)AddControl(new CText(SWS_STATICTEXT,m_CKAYAKText[m_CKAYAKIndex],txtInfo.m_rc, CMD_MSG_SUBSET_CABLEKAYAK));
	ResCon.SetTextParam(m_pCKAYAKText,txtInfo);


	m_CSAFEIndex=CConfig::GetInstance()->GetRegDWORD(L"CSAFE");
	ResCon.GetTextParam(txtInfo,L"CSAFE_TEXT");
	m_pCSAFEText = (CText*)AddControl(new CText(SWS_STATICTEXT,m_CSAFEText[m_CSAFEIndex],txtInfo.m_rc, CMD_MSG_SUBSET_CSAFETEXT));
	ResCon.SetTextParam(m_pCSAFEText,txtInfo);
	ChangeLangaue();


	SetPainter(new CSubConPainter());
	return true;
}
void CSubClubSetCon::ReLoadConfig()
{

    ChangeLangaue();

	
	 int m_UnitIndex=CConfig::GetInstance()->GetRegDWORD(TEXT("Unit_Weight_KG"));
     m_pUnitText->SetCaption( m_UnitText[m_UnitIndex]);
	m_CKAYAKIndex=CConfig::GetInstance()->GetRegDWORD(L"CABLEKAYAK");
	m_pCKAYAKText->SetCaption(m_CKAYAKText[m_CKAYAKIndex]);

	 m_CSAFEIndex=CConfig::GetInstance()->GetRegDWORD(L"CSAFE");
	 m_pCSAFEText->SetCaption(m_CSAFEText[m_CSAFEIndex]);

	 DWORD dwWorkTimer= CConfig::GetInstance()->GetMaxWorkoutTimes();//CConfig::GetInstance()->GetRegDWORD(L"MAXWorkTime");

	 m_pMaxTimeCtrl->Set_INT_Value(dwWorkTimer/60);
	 m_pMaxTimeCtrl->SetDecimalValue(dwWorkTimer%60);
	 if (m_pMaxTimeCtrl->Get_INT_Value()<=5)
	 {
		 m_pMaxTimeCtrl->Set_INT_Value(5);
		 m_pMaxTimeCtrl->SetDecimalValue(0);
	 }

	 if (m_pMaxTimeCtrl->Get_INT_Value()>=60)
	 {
		 m_pMaxTimeCtrl->Set_INT_Value(60);
		 m_pMaxTimeCtrl->SetDecimalValue(0);
	 }

	 DWORD dwPauseTimer=CConfig::GetInstance()->GetMaxPauseTimes();//CConfig::GetInstance()->GetRegDWORD(L"MAXPauseTime");
	
	 m_pPAUSETimeCtrl->Set_INT_Value(dwPauseTimer/60);
	 m_pPAUSETimeCtrl->SetDecimalValue(dwPauseTimer%60);
	 if (m_pPAUSETimeCtrl->Get_INT_Value()==0&&m_pPAUSETimeCtrl->GetDecimalValue()<=10)
	 {
		 m_pPAUSETimeCtrl->Set_INT_Value(0);
		 m_pPAUSETimeCtrl->SetDecimalValue(10);
	 }

	 if (m_pPAUSETimeCtrl->Get_INT_Value()>=2)
	 {
		 m_pPAUSETimeCtrl->Set_INT_Value(2);
		 m_pPAUSETimeCtrl->SetDecimalValue(0);
	 }





}

void CSubClubSetCon::OnCommand(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{


	switch (wParam)
	{
	case  CMD_MSG_SUBSET_BTN_MAXTIME_LEFT:

		{
          
			int nValue=m_pMaxTimeCtrl->Get_INT_Value();
			if (nValue==99)
			{
				nValue=100;
			}
			nValue=nValue-5;

			m_pMaxTimeCtrl->Set_INT_Value(nValue);
			;
			if (m_pMaxTimeCtrl->Get_INT_Value()<=5)
			{
				m_pMaxTimeCtrl->Set_INT_Value(5);
				m_pMaxTimeCtrl->SetDecimalValue(0);
			}
			if (lParam)
			{
				CRect rc;

				rc=m_pMaxTimeCtrl->GetRectCopy();
				m_pMaxTimeCtrl->SetRect(rc);

			}
			CRect rc=m_pMaxTimeCtrl->GetRect();
			
		
			rc.OffsetRect(GetRect().left,GetRect().top-m_iPage*m_iStep);
		    rc.right=rc.right-1;
			InvalidateRect(m_hWnd,rc,NULL);
		}

		break;
	case CMD_MSG_SUBSET_BTN_MAXTIME_RIGHT:
		{
			int nValue=m_pMaxTimeCtrl->Get_INT_Value();
		    nValue=nValue+5;
		
			m_pMaxTimeCtrl->Set_INT_Value(nValue);
			


		if (m_pMaxTimeCtrl->Get_INT_Value()>=99)
		{
			m_pMaxTimeCtrl->Set_INT_Value(99);
			m_pMaxTimeCtrl->SetDecimalValue(0);
		}
		if (lParam)
		{
			CRect rc;
		
			rc=m_pMaxTimeCtrl->GetRectCopy();

			m_pMaxTimeCtrl->SetRect(rc);
			
		
		}
		
		CRect rc=m_pMaxTimeCtrl->GetRect();
		
	
		rc.OffsetRect(GetRect().left,GetRect().top-m_iPage*m_iStep);
	   rc.right=rc.right-1;
		InvalidateRect(m_hWnd,rc,NULL);
		}
		break;
	case CMD_MSG_SUBSET_BTN_PAUSETIME_LEFT:
		{
			int iDecimalValue=m_pPAUSETimeCtrl->GetDecimalValue();
			iDecimalValue=iDecimalValue-30;
			if (iDecimalValue<0)
			{
				iDecimalValue=30;
				m_pPAUSETimeCtrl->Set_INT_Value(m_pPAUSETimeCtrl->Get_INT_Value()-1);

			}

			m_pPAUSETimeCtrl->SetDecimalValue(iDecimalValue);
			if (m_pPAUSETimeCtrl->Get_INT_Value()==0&&m_pPAUSETimeCtrl->GetDecimalValue()<=10)
			{
				m_pPAUSETimeCtrl->Set_INT_Value(0);
				m_pPAUSETimeCtrl->SetDecimalValue(30);
			}
			/*DWORD dwPauseTimer=m_pPAUSETimeCtrl->Get_INT_Value()*60+m_pPAUSETimeCtrl->GetDecimalValue();

			CConfig::GetInstance()->SetRegDWORD(L"MAXPauseTime",dwPauseTimer);*/
			if (lParam)
			{
				CRect rc;

				rc=m_pPAUSETimeCtrl->GetRectCopy();
				m_pPAUSETimeCtrl->SetRect(rc);

				rc=m_pPicPauseTime->GetRectCopy();

				m_pPicPauseTime->SetRect(rc);
					

			}
			CRect rc=m_pPAUSETimeCtrl->GetRect();
		
			rc.OffsetRect(GetRect().left,GetRect().top-m_iPage*m_iStep);
		    rc.right=rc.right-1;
			InvalidateRect(m_hWnd,rc,NULL);

         
		}
		break;
	case CMD_MSG_SUBSET_BTN_PAUSETIME_RIGHT:
		{
			int iDecimalValue=m_pPAUSETimeCtrl->GetDecimalValue();
			iDecimalValue=iDecimalValue+30;

			if (iDecimalValue==60)
			{
				iDecimalValue=0;
				m_pPAUSETimeCtrl->Set_INT_Value(m_pPAUSETimeCtrl->Get_INT_Value()+1);

			}
          	m_pPAUSETimeCtrl->SetDecimalValue(iDecimalValue);
			if (m_pPAUSETimeCtrl->Get_INT_Value()>=5)
			{
             m_pPAUSETimeCtrl->Set_INT_Value(5);
			 m_pPAUSETimeCtrl->SetDecimalValue(0);
			}
		
			if (lParam)
			{
				CRect rc;

				rc=m_pPAUSETimeCtrl->GetRectCopy();
			
				m_pPAUSETimeCtrl->SetRect(rc);

				rc=m_pPicPauseTime->GetRectCopy();

				m_pPicPauseTime->SetRect(rc);

			}

           /*  DWORD dwPauseTimer=m_pPAUSETimeCtrl->Get_INT_Value()*60+m_pPAUSETimeCtrl->GetDecimalValue();

			CConfig::GetInstance()->SetRegDWORD(L"MAXPauseTime",dwPauseTimer);*/
			CRect rc=m_pPAUSETimeCtrl->GetRect();
		
			rc.OffsetRect(GetRect().left,GetRect().top-m_iPage*m_iStep);
			rc.right=rc.right-1;
			InvalidateRect(m_hWnd,rc,NULL);

		}
		break;

	case CMD_MSG_CLUBSET_BTN_KAYA:
		{
			m_CKAYAKIndex--;
			if(m_CKAYAKIndex < 0)
			{
				m_CKAYAKIndex = m_CKAYAKText.size() -1;
			}
			m_pCKAYAKText->SetCaption(m_CKAYAKText[m_CKAYAKIndex]);
			//CConfig::GetInstance()->SetRegDWORD(L"CABLEKAYAK",m_CKAYAKIndex);
			CRect rc=m_pCKAYAKText->GetRect();
			rc.OffsetRect(GetRect().left,GetRect().top-m_iPage*m_iStep);
			InvalidateRect(m_hWnd,rc,NULL);
		}
		break;
	case  CMD_MSG_SUBSET_BTN_UNIT:
	
		{
			m_UnitIndex--;
			if(m_UnitIndex < 0)
			{
				m_UnitIndex = m_UnitText.size() -1;
			}
			m_pUnitText->SetCaption(m_UnitText[m_UnitIndex]);

			//CConfig::GetInstance()->SetUnitS(m_UnitText[m_UnitIndex]);
			CRect rc=m_pUnitText->GetRect();
			//rc.MoveToXY(m_pUnitText->GetRect().left,m_pUnitText->GetRect().top-m_iPage*m_iStep);
			rc.OffsetRect(GetRect().left,GetRect().top-m_iPage*m_iStep);

			InvalidateRect(m_hWnd,rc,NULL);
		}
		break;
	case CMD_MSG_CLUBSET_BTN_CSAFE:
		{  
            m_CSAFEIndex--;
			if(m_CSAFEIndex < 0)
			{
				m_CSAFEIndex = m_CKAYAKText.size() -1;
			}
			m_pCSAFEText->SetCaption(m_CSAFEText[m_CSAFEIndex]);
				CConfig::GetInstance()->SetRegDWORD(L"CSAFE",m_CSAFEIndex);
				//CConfig::GetInstance()->SetUnitS(m_UnitText[m_UnitIndex]);
				CRect rc=m_pCSAFEText->GetRect();
				rc.OffsetRect(GetRect().left,GetRect().top-m_iPage*m_iStep);
                 InvalidateRect(m_hWnd,rc,NULL);
		}
		break;
	}

}

void CSubClubSetCon::SaveConfig()
{


	DWORD dwWorkTimer=m_pMaxTimeCtrl->Get_INT_Value()*60+m_pMaxTimeCtrl->GetDecimalValue();

	
    CConfig::GetInstance()->SetMaxWorkoutTimes(dwWorkTimer);
	DWORD dwPauseTimer=m_pPAUSETimeCtrl->Get_INT_Value()*60+m_pPAUSETimeCtrl->GetDecimalValue();

    CConfig::GetInstance()->SetMaxPauseTimes(dwPauseTimer);
//	CConfig::GetInstance()->SetRegDWORD(L"MAXPauseTime",dwPauseTimer);

	CConfig::GetInstance()->SetRegDWORD(L"CABLEKAYAK",m_CKAYAKIndex);
	//CConfig::GetInstance()->SetUnitS(m_UnitText[m_UnitIndex]);

    CConfig::GetInstance()->SetRegDWORD(TEXT("Unit_Weight_KG"),m_UnitIndex);
	CConfig::GetInstance()->SetRegDWORD(L"CSAFE",m_CSAFEIndex);

	
	

}